<?php
class WenbonAction extends Action {
     Public function _initialize(){
        $this->site=M('site')->find(1);
     }
     Public function _empty(){
        if(empty($cid)) $this->error('页面不存在！');
     }
     Public function a(){
        
        $cid=I('cid');
        if(empty($cid)) $this->error('页面不存在！');
        
        $type=M('category')->find($cid);
        if($type['access']==3) $this->error('禁止访问！');
        if($type['access']==2 && (Session('muid')==null)) $this->error('无权访问！');
        $type['url']=U('Wenbon/a',array('cid'=>$type['id']));
        
        $this->position=formatCat(getparents(M('category')->select(),$cid));
        $this->type=$type;
        $this->display($type['module'].'/'.$type['list']);
     }
     Public function b(){
        $id=I('id');
        $tag=I('t');
        if(empty($id)) $this->error('页面不存在！');
        if(empty($tag)) $this->error('页面不存在！');
        
        $body=D('Content')->table(C('DB_PREFIX').$tag)->relation(true)->where(array('id'=>$id))->select();
        $body=formatCon($body); 
        $body=$body[0];   
        $type=M('category')->find($body['cid']);
        $type['url']=U('Wenbon/a',array('cid'=>$type['id']));
        
        //该条信息的访问权限
        if($body['access']==0){
            if($type['access']==3) $this->error('禁止访问！');
            if($type['access']==2 && (Session('muid')==null)) $this->error('无权访问！');
        }
        else{
            if($body['access']==3) $this->error('禁止访问！');
            if($body['access']==2 && (Session('muid')==null)) $this->error('无权访问！');
        }
        
        $this->body=$body;
        $this->type=$type;
        $this->position=formatCat(getparents(M('category')->select(),$body['cid']));
        D('Content')->table(C('DB_PREFIX').$tag)->relation(true)->where(array('id'=>$id))->setInc('account');//访问加1
        $this->display($type['module'].'/'.$type['content']);
     }
}
?>